package org.mar.sort;


public class BubbleSort implements Sort {
    public static void main(String[] args) {
        SortUtil.testSorted(new BubbleSort());
    }

    public void sort(int[] array) {
        if (array == null || array.length == 0) {
            return;
        }
        for (int border = array.length - 1; border > 0; border--) {
            for (int i = 0; i < border; i++) {
                if (array[i] > array[i + 1]) {
                    int tmp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = tmp;
                }
            }
        }
    }
}
